package com.boyu.front;

import com.boyu.common.BaseController;
import com.boyu.common.SystemConst;
import com.boyu.common.model.Article;
import com.jfinal.plugin.activerecord.Page;

/**
 * IndexController
 */
public class ArticleController extends BaseController {

    public static final int QIYECAIGOU_ARTICLE_ID = 5;
    public static final int SHOUHOU_ARTICLE_ID = 6;
    public static final int ADDRESS_ARTICLE_ID = 13;

    /**
     * 首页滚动图片
     */
    public static final int INDEX_ROLL_IMAGE_OPTION_ID = 16;

    /**
     * 俱乐部滚动图片
     */
    public static final int CLUB_ROLL_IMAGE_OPTION_ID = 32;

    /**
     * 企业采购滚动图片
     */
    public static final int BUY_ROLL_IMAGE_OPTION_ID = 42;
    /**
     * 直营店滚动图片
     */
    public static final int ADDRESS_ROLL_IMAGE_OPTION_ID = 34;
    /**
     * 售后滚动图片
     */
    public static final int SALE_AFTER_ROLL_IMAGE_OPTION_ID = 35;
    /**
     * 大行咨询滚动图片
     */
    public static final int NEWS_ROLL_IMAGE_OPTION_ID = 36;


    public static final String OPTION_ID = "optionId";

    /**
     * 直营店地址detailId
     */
    public static final int ADDRESS_DETAIL_ID = 20;


    /**
     * 企业采购
     */
    public void qiyecaigou() {
        Article article = articleService.get(QIYECAIGOU_ARTICLE_ID);
        setAttr("article", article);
        setAttr(OPTION_ID, BUY_ROLL_IMAGE_OPTION_ID);
        render("qiyecaigou.html");
    }

    /**
     * 售后政策
     */
    public void shouhou() {
        Article article = articleService.get(SHOUHOU_ARTICLE_ID);
        setAttr("article", article);
        setAttr(OPTION_ID, SALE_AFTER_ROLL_IMAGE_OPTION_ID);
        render("shouhou.html");
    }

    /**
     * 俱乐部活动
     */
    public void club() {
        setAttr("cur", "club");
        setAttr(OPTION_ID, CLUB_ROLL_IMAGE_OPTION_ID);
        Page<Article> page = articleService.getPage(13, 1);
        setAttr("page", page);
        render("club.html");
    }

    /**
     * 实体店地址
     */
    public void address() {
        Article article = articleService.get(ADDRESS_ARTICLE_ID);
        setAttr("article", article);
        setAttr(OPTION_ID, ADDRESS_ROLL_IMAGE_OPTION_ID);
        render("address.html");
    }

    /**
     * 大行新闻
     */
    public void news() {
        setAttr("cur", "news");
        Page<Article> page = articleService.getPage(1, 1);
        setAttr(OPTION_ID, NEWS_ROLL_IMAGE_OPTION_ID);
        setAttr("page", page);
        render("club.html");
    }

    /**
     * 视频
     */
    public void vedio() {
        setAttr("cur", "vedio");
        Page<Article> page = articleService.getPage(2, 1);
        setAttr("page", page);
        setAttr(OPTION_ID, NEWS_ROLL_IMAGE_OPTION_ID);
        render("club.html");
    }

    /**
     * 啤酒咖啡
     */
    public void pijiu() {
        setAttr("cur", "pijiu");
        Page<Article> page = articleService.getPage(18, 1);
        setAttr("page", page);
        render("club.html");
    }

    /**
     * 专利
     */
    public void zhuanli() {
        Page<Article> page = articleService.getPage(17, 1);
        setAttr("page", page);
        render("club.html");
    }

    /**
     * 新闻详情
     */
    public void detail() {
        Integer id = getParaToInt("id");
        Article article = articleService.get(id);
        setAttr("article", article);
        setAttr(SystemConst.FRONT_TITLE, article.getTitle());
        if (id == ADDRESS_DETAIL_ID) {
            setAttr(OPTION_ID, ADDRESS_ROLL_IMAGE_OPTION_ID);
        } else {
            setAttr(OPTION_ID, NEWS_ROLL_IMAGE_OPTION_ID);
        }
        render("detail.html");
    }
}





